package com.company.controller;

import com.company.common.R;
import com.company.entity.Pet;
import com.company.service.PetService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class PetController {
    @Resource
    PetService petService;

    /*
     * 用户分页
     * */
    @CrossOrigin(origins = "*")
    @RequestMapping("/selectAllPet/{page}")
    public R selectAllPet(@PathVariable("page") int page){
        //第一个参数表示第几页，第二个参数表示每页的条数
        PageHelper.startPage(page,4);
        List<Pet> list=this.petService.list();
        PageInfo<Object> pageInfo = new PageInfo<>(list);
        return new R().add("pageInfo",pageInfo);
    }

}
